package test3;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SogouMapper extends Mapper<LongWritable, Text, Text, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String data = new String(value.toString());
        String word[] = data.split("\\s+");
        if (word.length != 6) {
            return;
        }
        String newData = data.replaceAll("\\s+", ",");
        String words[] = newData.split(",");
        if (words[3].equals("2") && words[4].equals("1")) {
            context.write(new Text(newData), NullWritable.get());
        } else {
            return;
        }
    }
}